import React, { useEffect, useState } from 'react'
import { Link } from 'react-router-dom'
import { store_name } from '../../../util'

function HomePage() {
  const [workspaces, setWorkspaces] = useState<Workspace[]>([])
  useEffect(() => {
    chrome.storage.local.get(store_name, ({ workspaces }) => {
      setWorkspaces(workspaces)
    })
  })
  return (
    <div className="App">
      <h2>我的workSpace空间</h2>
      <div>
        {workspaces.map(item => (
          <Link to={`/workspace/${item.name}`}>{item.name}</Link>
        ))}
      </div>
    </div>
  )
}

export default HomePage
